import com.atshiyou.bean.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.Reader;
import java.util.List;

public class TestSqlSession {
    public static void main(String[] args) throws Exception {
//        1、加载配置文件
        Reader reader = Resources.getResourceAsReader("mybatis.xml");
        //2、得到SqlSessionFactoryBuilder
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory build = builder.build(reader,"development2");
        //3、得到session对象
        SqlSession session = build.openSession();
        // 4、操作SQL
        List<Student> lists = session.selectList("com.atshiyou.dao.StudentDao.findAll");
        System.out.println("-------------------");
        lists = session.selectList("com.atshiyou.dao.StudentDao.findAll");

        session.close();
        reader.close();

    }
}
